<?php
/* wwwschool project
Copyright (C) 2009  Phillip Aldridge
Email : info@imi21.com
Web site http://www.imi21.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/**
 *
 *  wwwschool project
 *  File : WS3user.php
 *  
 * CLASS WS3_User
 */  
 
 class WS3_User {
 
  private $id = null; 
  private $last_name = null;
  private $first_name = null; 
  private $email = null; 
  private $active = false;
  private $user_type = false; 
   
   public function __construct() {
   }
   
   public function __destruct() {
   }
   
  // set User id
  function setUserID($id=null) {   
    $db = new WS3_Database();
    $id = $db->makeSafeInt($id);
    $q = "SELECT * FROM `user` WHERE id='$id' LIMIT 1";
    if ($db->query($q) && $db->nextRecord() )
    {
      $this->id = $db->f('id');
      $this->last_name = javaSafeString( $db->f('last_name') );
      $this->first_name = javaSafeString( $db->f('first_name') );
      $this->email = $db->f('email');
      $this->active = $db->f('active');
      $this->user_type = $db->f('user_type');
      return true;
    }else
    {
      return false;
    }
   }
   


  // get id
  function ID() {
    if ($this->id)
    return $this->id;
    else
    return false;
  }
  
  // get last_name
  function LastName() {
    if ( $this->last_name )
    return $this->last_name;
    else
    return false;
   }   
 
  // get first_name
  function FirstName() {
    if ( $this->first_name )
    return $this->first_name;
    else
    return false;
   }   
   // get full_name
  function FullName() {
    $s= $this->FirstName()." ". $this->LastName();
    return $s;
   } 
   // get type
  function UserType() {
    if ( $this->user_type  )
    return $this->user_type ;
    else
    return false;
   } 
           
   // 
  function isActive() {
    if ( $this->active )
    return true;
    else
    return false;
   }    
   // 
  function Email() {
    if ( $this->email )
    return $this->email;
    else
    return false;
   }     
 } // end class
 
 ?>